﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WebApplication1.Controllers.Domain
{
    public class DbInitializeHelper
    {
        public static void Initilizer()
        {
            using (var db = new Admin4000DbContext())
            {
                var a = db.Database.EnsureCreated();

                var tempBrand = db.Brands.Any();

                if (!a)
                {
                    var brand = new Brand
                    {
                        BrandName = "汶霖",
                        Description = "宿舍底层群员"
                    };
                    db.Brands.Add(brand);

                    db.SaveChanges();

                    db.Products.AddRange(new Product[]{
                    new Product
                    {
                        ProductName = "谢姐姐",
                        ShortDesc = "女生",
                        FullDesc="人见人爱",
                        BrandId =brand.id
                    },
                    new Product
                    {
                        ProductName = "谢弟弟",
                        ShortDesc = "男生",
                        FullDesc="渣男",
                        BrandId =brand.id
                    }
                });
                    db.SaveChanges();
                }
            }
        }
    }
}
